<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        var arr = ['pink','hot','blue','yellow','orange'];
        // var tep = '|';
        var result = '';
        for (var i = 0; i < arr.length; i++) {
            // if (i === arr.length - 1) {
            //     result += arr[i]; 
            // } else {
            //     result += arr[i] + tep;
            // }
            // i === arr.length - 1?result += arr[i]:result += arr[i] + '|';
            result += arr[i] + (i === arr.length-1? '':'|');
        }
        console.log(result);


        var arr = ['pink','hot','blue','yellow','orange'];

        // 在最前面追加元素
        arr.unshift('12');

        // 在最后面追加元素
        arr.push('nihao');

        console.log(arr);

    </script>
</body>
</html>